home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-08-15 | 3.0 KB | 114 lines | [TEXT/CCL2] |
- ;;;
- ;;; sound-scrap.lisp
- ;;;
-
- #|
- ================================================================
- Purpose ========================================================
- ================================================================
- Created from Apple's Pict-Scrap.Lisp, defines a scrap-handler for scraps of
- type :|snd | .
-
-
- ================================================================
- Status =========================================================
- ================================================================
- Implemented.
-
-
- ================================================================
- Change history =================================================
- ================================================================
- 15-Aug-92 mc Created.
-
- |#
-
-
- (in-package "CCL")
-
-
- ;;;================================================================
- ;;; Define the sound-scrap-handler class and methods.
- ;;;================================================================
-
- (defclass sound-scrap-handler (scrap-handler)
- () ;no new slots
- )
-
-
- (defmethod set-internal-scrap ((self sound-scrap-handler) scrap)
- (declare (optimize speed))
- ;;
- (let* ((old-sound (slot-value self 'internal-scrap)))
- (when (handlep old-sound)
- ;(#_KillSound old-sound) ;dispose of the old sound?
- ))
- (call-next-method self scrap)
- (when scrap (pushnew :|snd | *scrap-state*)))
-
-
- (defmethod externalize-scrap ((sound-scrap-handler sound-scrap-handler))
- (declare (optimize speed))
- ;;
- (let* ((the-sound (slot-value sound-scrap-handler 'internal-scrap))
- (size (#_GetHandleSize the-sound)))
- (when the-sound
- (with-dereferenced-handles
- ((the-sound the-sound))
- (#_PutScrap size :|snd | the-sound)))))
-
-
- (defmethod internalize-scrap ((sound-scrap-handler sound-scrap-handler))
- (declare (optimize speed))
- ;;
- (let* ((the-sound (#_NewHandle 0)))
- (rlet ((junk :signed-long))
- (#_GetScrap the-sound :|snd | junk))
- (setf (slot-value sound-scrap-handler 'internal-scrap) the-sound)))
-
-
- (defmethod get-internal-scrap ((sound-scrap-handler sound-scrap-handler))
- (declare (optimize speed))
- ;;
- (slot-value sound-scrap-handler 'internal-scrap))
-
-
- ;;; Done.
-
- (pushnew `(:|snd | . ,(make-instance 'sound-scrap-handler))
- *scrap-handler-alist*
- :test #'equal)
-
- (provide "SOUND-SCRAP")
-
-
-
- #|
- ;;; Define sound-window, which supports pasting sounds.
- ;;;
- ;;; Because it doesn't remember the sounds it pastes it can't cut.
- ;;;
-
- (defclass sound-window (window)
- () ;no new slots
- (:default-initargs
- :window-title "Sound Window"))
-
-
- (defmethod paste ((sound-window sound-window))
- ;;
- (let* ((h-sound (get-scrap :|snd |)))
- (when h-sound
- (#_HLock h-sound)
- (#_LoadResource h-sound)
- (let* ((int-play-error (#_SndPlay (%null-ptr) h-sound t))) ;t = async
- (#_HUnLock h-sound)
- ;; Warn of error if failed.
- (when (minusp int-play-error)
- (warn "Error ~S playing ~S." int-play-error h-sound))))))
-
-
- (make-instance 'sound-window)
-
- |#
-